public class test {
    public static void main(String[] args) {
        String str = "Hello, World!";
        int count = 100000;
        long startTime, endTime;

        // 测试StringBuilder
        startTime = System.currentTimeMillis();
        testStringBuilder(str, count);
        endTime = System.currentTimeMillis();
        System.out.println("StringBuilder: " + (endTime - startTime) + " ms");

        // 测试StringBuffer
        startTime = System.currentTimeMillis();
        testStringBuffer(str, count);
        endTime = System.currentTimeMillis();
        System.out.println("StringBuffer: " + (endTime - startTime) + " ms");
    }

    public static void testStringBuilder(String str, int count) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < count; i++) {
            sb.append(str);
        }
    }

    public static void testStringBuffer(String str, int count) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < count; i++) {
            sb.append(str);
        }
    }
}